import request from '@/router/axios';

// 素材
export const offerCreativePage = params => {
  return request({
    url: '/api/beetles-offer/creative/page',
    method: 'GET',
    params
  })
}

// 获取兴趣api
export const getTiktokInterestTree = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/get-interest-categories',
    method: 'GET',
    params
  })
}

// 添加行为，视频，创作者
export const getActionCategories = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/get-action-categories',
    method: 'GET',
    params
  })
}

// 批量添加
export const createAdCampaign = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/batch-create-ad-campaign',
    method: 'POST',
    data
  })
}

// 获取受众列表
export const getAudiencesInfo = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/get-audiences-info',
    method: 'GET',
    params
  })
}

// 获取应用内事件
export const getOptimizationEvent = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/get-optimization-event',
    method: 'GET',
    params
  })
}

// campaign分页查询
export const getTiktokCampaignPage = (params, data) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/page',
    method: 'POST',
    params,
    data
  })
}

export const checkAdGroupExist = (campaignId) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/check-ad-group-exist',
    method: 'GET',
    params: {
      campaignId: campaignId
    }
  })
}

export const editSingleCampaign = (data) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/edit-campaign',
    method: 'POST',
    data: data
  })
}

export const editSingleAdGroup = (data) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/edit-ad-group',
    method: 'POST',
    data: data
  })
}


// campaign任务列表分页查询
export const getCampaignTaskPage = params => {
  return request({
    url: '/api/beetles-offer/campaign-task/page',
    method: 'GET',
    params
  })
}

// 广告组表分页查询
export const getAdGroupPage = (params, data) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/page',
    method: 'POST',
    params,
    data
  })
}

// 广告表分页查询
export const getAdPage = (params, data) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad/page',
    method: 'POST',
    params,
    data
  })
}

// 查询身份
export const getTtIdentity = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/get-tt-identity',
    method: 'GET',
    params
  })
}
// 添加身份
export const createTtIdentity = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/create-tt-identity',
    method: 'GET',
    params
  })
}

// 广告组状态修改
export const changeAdGroupStatus = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/switch',
    method: 'PUT',
    params
  })
}

// 广告状态修改
export const changeAdStatus = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad/switch',
    method: 'PUT',
    params
  })
}

// 广告系列状态修改
export const changeCampaignStatus = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/switch',
    method: 'PUT',
    params
  })
}

//获取广告系列的受众信息
export const getAudiencesInfoByAdGroup = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/get-audiences-info-by-ad-group',
    method: 'GET',
    params
  })
}


// 广告组名字修改
export const updateGroupName = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/update-group-name',
    method: 'PUT',
    params
  })
}

// 广告名修改
export const updateAdName = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad/update-ad-name',
    method: 'PUT',
    params
  })
}

// 广告系列状态名修改
export const updateCampaignName = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/update-campaign-name',
    method: 'PUT',
    params
  })
}

// 广告系列状态修改
export const saveTask = data => {
  return request({
    url: '/api/beetles-offer/campaign-task/save-task',
    method: 'POST',
    data
  })
}

// 查询身份根据广告组
export const getTtIdentityByAdGroup = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/get-tt-identity-by-ad-group',
    method: 'GET',
    params
  })
}

// 编辑广告
export const editAd = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad/edit-ads',
    method: 'POST',
    data: data
  })
}

// 根据广告组添加身份
export const createTtIdentityByAdGroup = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/create-tt-identity-by-ad-group',
    method: 'GET',
    params
  })
}

// 批量更新广告系列状态
export const batchUpdateCampaignStatus = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/batch-update-status',
    method: 'PUT',
    data: data
  })
}

// 批量更新广告组状态
export const batchUpdateAdGroupStatus = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/batch-update-status',
    method: 'PUT',
    data: data
  })
}

// 批量更新广告组预算
export const batchUpdateAdGroupBudget = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/batch-update-budget',
    method: 'PUT',
    data: data
  })
}

// 获取tiktok AD 层级受众信息数据
export const getAdAudiencesDataList = params => {
  return request({
    url: '/api/beetles-offer/beetles-offer/tiktok-campaign/ad/get-audiences-data-list',
    method: 'GET',
    params
  })
}

// 获取campaign受众数据查询
export const getCampaignAudiencesDataList = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/get-audiences-data-list',
    method: 'GET',
    params
  })
}

// 广告组受众数据查询
export const getAdGroupAudiencesDataList = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/get-audiences-data-list',
    method: 'GET',
    params
  })
}

// 广告组受众数据查询
export const getIos14Quota = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/get-ios14-quota',
    method: 'GET',
    params
  })
}

// 查找所有的canpaign
export const getCampaignList = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/list',
    method: 'GET',
    params
  })
}

// 批量修改广告系列预算
export const batchUpdateCampaignBudget = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/batch-update-budget',
    method: 'PUT',
    data: data
  })
}

// 批量修改广告系列名字
export const batchUpdateCampaignNames = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/batch-update-name',
    method: 'PUT',
    data: data
  })
}

// 批量修改广告组名字
export const batchUpdateAdgroupNames = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/batch-update-name',
    method: 'PUT',
    data: data
  })
}

// 批量修改广告组出价
export const batchUpdateAdgroupBid = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/batch-update-bid',
    method: 'PUT',
    data: data
  })
}

export const updateCampaignBudget = (id, budget) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/update-budget',
    method: 'POST',
    params: {
      id,
      budget,
    }
  })
}

export const updateAdgroupBudget = (id, budget) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/adgroup/update-budget',
    method: 'POST',
    params: {
      id,
      budget,
    }
  })
}

export const updateAdgroupBid = (id, bid) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/adgroup/update-bid',
    method: 'POST',
    params: {
      id,
      bid,
    }
  })
}

export const getCampaignCost = (data) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/get-cost',
    method: 'POST',
    data: data
  })
}

export const getAdgroupCost = (data) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/get-cost',
    method: 'POST',
    data: data
  })
}

// 查找所有的广告组
export const getAdGroupList = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/list',
    method: 'GET',
    params
  })
}

// 广告组复制提交
export const createBatchAdGroup = (campaignId, data) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/batch-create',
    method: 'POST',
    params: {
      campaignId
    },
    data
  })
}

// 广告复制提交
export const createBatchAd = (adGroupId, data) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad/batch-create',
    method: 'POST',
    params: {
      adGroupId
    },
    data
  })
}

// 获取账户下所有APP
export const getAccountAppList = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/get-account-app-list',
    method: 'GET',
    params
  })
}

// 获取账户下所有APP
export const getAccountListByAppId = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/get-account-list-by-app-id',
    method: 'GET',
    params
  })
}

// 获取订单下所有文案
export const getTextList = (offerId) => {
  return request({
    url: '/api/beetles-offer/creative-text/list',
    method: 'GET',
    params: {
      offerId,
    }
  })
}

// 获取地区
export const getLocationTree = params => {
  return request({
    url: '/api/blade-system/dict-biz/tiktok/location-tree',
    method: 'GET',
    params
  })
}

// 请求事件接口
export const getTiktokCampaignEventData = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/get-event-data',
    method: 'POST',
    data
  })
}

// 请求事件接口
export const getTiktokAdGroupEventData = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/get-event-data',
    method: 'POST',
    data
  })
}

// 请求事件接口
export const getTiktokAdEventData = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad/get-event-data',
    method: 'POST',
    data
  })
}

// 查询是否可复制
export const checkCopyable = (campaignId) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/check-copyable',
    method: 'GET',
    params: {
      campaignId,
    }
  })
}

// 获取其它兴趣
export const getInterestByKeyword = (accountId, keyword) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/interest_by_keyword',
    method: 'GET',
    params: {
      accountId,
      keyword,
    }
  })
}

//保存自定义事件模板
export const saveCustomTtEventTemplate = (data) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/save_custom_tt_event_template',
    method: 'POST',
    data: data
  })
}

//获取自定义事件模板
export const getCustomTtEventTemplate = (offerId, userId) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/get_custom_tt_event_template',
    method: 'GET',
    params: {
      offerId,
      userId,
    }
  })
}

//获取自定义事件模板
export const delCustomTtEventTemplate = (id) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/del_custom_tt_event_template',
    method: 'DELETE',
    params: {
      id
    }
  })
}

// 检查广告系列名称是否重名
export const checkCampaignName = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/check-name',
    method: 'GET',
    params
  })
}

// 检查广告组名称是否重名
export const checkAdGroupName = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/check-name',
    method: 'GET',
    params
  })
}

//获取编辑aco的广告信息
export const getAcoDetail = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad/get-aco-ad-detail',
    method: 'GET',
    params
  })
}

export const editAcoDetail = (data) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad/edit-aco-ads',
    method: 'POST',
    data: data
  })
}

// 复制推广系列
export const confirmCopyCampaign = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/confirm-copy',
    method: 'POST',
    params
  })
}

// params {adGroupId}
export const getCopyAdgroupDetail = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/get-copy-adgroup-detail',
    method: 'GET',
    params
  })
}

// 查询广告组底下的广告
export const getFormatAdByAdGroup = (adGroupId, creativeMaterialMode) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad/generate-web-ad-format',
    method: 'GET',
    params: {
      adGroupId,
      creativeMaterialMode
    }
  })
}


// 批量更新广告组状态
export const batchUpdateAdStatus = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad/batch-update-status',
    method: 'PUT',
    data: data
  })
}

export const getLandingPageList = platformId => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/get-page-list',
    method: 'GET',
    params: {
      platformId
    }
  })
}

export const getLocationTreeByTargeting = () => {
  return request({
    url: '/api/blade-system/dict-biz/tiktok/location-tree-by-targeting',
    method: 'GET',
  })
}


export const batchUpdateTarget = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/adgroup/batch-update-targeting',
    method: 'POST',
    data: data
  })
}

export const getCreators = (offerId) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/creator-list',
    method: 'GET',
    params: {offerId: offerId}
  })
}

//获取智能封面
export const getSuggestCover = (accountId, creativeId) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad/get-suggest-cover',
    method: 'GET',
    params: {accountId: accountId, creativeId: creativeId}
  })
}

// 推广系列合计
export const getCampaignTotalData = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/campaign/get-total-data',
    method: 'POST',
    data
  })
}

// 广告组合计
export const getAdGroupTotalData = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad-group/get-total-data',
    method: 'POST',
    data
  })
}

// 广告合计
export const getAdTotalData = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad/get-total-data',
    method: 'POST',
    data
  })
}

//上传智能封面
export const uploadTtCover = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad/upload-suggest-cover',
    method: 'POST',
    data
  })
}

export const getAdCover = (adId) => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/ad/get-ad-cover',
    method: 'GET',
    params: {adLocalId: adId}
  })
}

// 创建广告模板
export const createTiktokCampaignTemplate = data => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/create-template',
    method: 'POST',
    data
  })
}

// 获取广告模板
export const getTiktokCampaignTemplateList = params => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/get-template-list',
    method: 'GET',
    params
  })
}

// 获取广告模板
export const removeTiktokCampaignTemplateList = id => {
  return request({
    url: '/api/beetles-offer/tiktok-campaign/remove-template',
    method: 'DELETE',
    params: {
      id
    }
  })
}
